/**
 * 定义站点模块
 */
(function(window, angular, undefined){

	var module = angular.module('water.entity.commonEntity',['waterCommon']);
	
	module.service('$commonEntityService',function($waterDataCommon){
		
		/**
		 * 查询列表
		 * {
		 * 	WWTP_ID:'',
		 *  STATION_ID:''
		 * }
		 */
		this.getList = function(tableName,queryObj){
			if(!tableName){
				console.log("tableName 不能为空");
				return ;
			}
			var promise = $waterDataCommon.post("/form/"+tableName+"/getPageRows",queryObj);
			return promise;
		}
		/**
		 * 获取model
		 */
		this.getModel = function(tableName,key){
			if(!tableName){
				console.log("tableName 不能为空");
				return ;
			}
			if(!key){
				console.log("key 不能为空");
				return ;
			}
			var promise = $waterDataCommon.getModel(tableName,key);
			return promise;
		}
		/**
		 * 新建model
		 */
		this.createModel = function(tableName,model){
			if(!tableName){
				console.log("tableName 不能为空");
				return ;
			}
			if(!model){
				console.log("model 不能为空");
				return ;
			}
			var promise = $waterDataCommon.createModel(tableName,model);
			return promise;
		}
		/**
		 * 更新model
		 */
		this.updateModel = function(tableName,model){
			if(!tableName){
				console.log("tableName 不能为空");
				return ;
			}
			if(!model){
				console.log("model 不能为空");
				return ;
			}
			var promise = $waterDataCommon.updateModel(tableName,model);
			return promise;
		}
		/**
		 * 删除model
		 */
		this.deleteModel = function(tableName,key){
			if(!tableName){
				console.log("tableName 不能为空");
				return ;
			}
			if(!key){
				console.log("key 不能为空");
				return ;
			}
			var promise = $waterDataCommon.deleteModel(tableName,{key:key});
			return promise;
		}
	})
}(window, angular));